import Vue from 'vue';
import Vuex from 'vuex';
import $md5 from 'js-md5';

Vue.use(Vuex);


let state = {
    name:"hlg",
    code:'',
    categoryUrl:'http://cloud_2019.dyrs.com.cn',
    param:null
  };

const mutations = {
    setCode(state,param){
        state.code = param;
    },
    getParam(){
      state.param =  {
        callbackQuery: "callback", // jsonp key //请求传递参数 1
        callbackName: "jsonpCallback", // jsonp key //请求传递参数 2
        timestamp: Date.parse(new Date()) / 1000,
        token: $md5(
        $md5("dyrs_$&*2019") + Date.parse(new Date()) / 1000
        ),
        response_type: 'jsonp'
      }
    }
    
 };
 const getters = {
  
 }

 export default new Vuex.Store({
    state,
    mutations,
    // actions,
    getters
  })

// dispatch：含有异步操作，例如向后台提交数据，写法： this.$store.dispatch('mutations方法名',值)
// commit：同步操作，写法：this.$store.commit('mutations方法名',值)